package com.ipinyou.hbase;

import java.io.IOException;
import java.util.List;

import org.apache.hadoop.hbase.client.HConnection;
import org.apache.hadoop.hbase.client.HTableInterface;
import org.junit.Test;

import com.ipinyou.hbase.model.MUser;
import com.ipinyou.hbase.service.HBaseConnectionService;
import com.ipinyou.hbase.service.impl.HBaseConnectionServiceImpl;

public class testHBaseConnectionService {
	static HBaseConnectionService hBaseConnectionService = new HBaseConnectionServiceImpl();
	static MUser apple = new MUser();
	static {
		apple.setId("yujia.miao");
		apple.setContent("23");
	}

	@Test
	public void testInsert() {
		hBaseConnectionService.insert(apple);
	}

	@Test
	public void testDelete() {
		hBaseConnectionService.delete("crawldbtest", "123");
	}

	@Test
	public void testGet() {
		List<MUser> objs = hBaseConnectionService.get(apple, "yujia.miao");
		for (MUser obj : objs) {
			System.out.println(obj.getId());
			System.out.println(obj.getContent());
		}
	}

	@SuppressWarnings("deprecation")
	@Test
	public void testGetConnection() throws IOException {
		HConnection hbaseConnection = hBaseConnectionService.getHbaseConnection();
		System.out.println(hbaseConnection);
		HTableInterface table = hbaseConnection.getTable("mprofile");
		System.out.println(table);

	}

}
